﻿using System.Collections.Generic;
using Newtonsoft.Json;

namespace Ecobee.Net
{
	/// <summary>
	/// The response status object contains the processing status of the request. It will contain 
	/// any relevant error information should an error occur. The status object is returned with 
	/// every response regardless of success or failure status. It is suitable for logging request 
	/// failures.
	/// </summary>
	public class Status : ApiObject
	{
		private static List< Status> _knownCodes = new List<Status>();
		private int _code = 0;
		private string _message = string.Empty;

		static Status()
		{
			//Status.KnownCodes.Add(new Status() { Code = 0, Message = "Success: Your request was successfully received and processed." });
			//Status.KnownCodes.Add(new Status() { Code = 1, Message = "Authentication failed: Invalid credentials supplied to the registration request, or invalid token. Request registration again." });
			//Status.KnownCodes.Add(new Status() { Code = 2, Message = "Not authorized: Attempted to access resources which user is not authorized for. Ensure the thermostat identifiers requested are correct." });
			//Status.KnownCodes.Add(new Status() { Code = 3, Message = "Processing error: General catch-all error for a number of internal errors. Additional info may be provided in the message. Check your request. Contact support if persists." });
			//Status.KnownCodes.Add(new Status() { Code = 4, Message = "Serialization error: An internal error mapping data to or from the API transmission format. Contact support." });
			//Status.KnownCodes.Add(new Status() { Code = 5, Message = "Invalid request format: An error mapping the request data to internal data objects. Ensure that the properties being sent match properties in the specification." });
			//Status.KnownCodes.Add(new Status() { Code = 6, Message = "Too many thermostat in selection match criteria: Too many identifiers are specified in the Selecton.selectionMatch property. Current limit is 25 per request." });
			//Status.KnownCodes.Add(new Status() { Code = 7, Message = "Validation error: The update request contained values out of range or too large for the field being updated. See the additional message information as to what caused the validation failure." });
			//Status.KnownCodes.Add(new Status() { Code = 8, Message = "Invalid function: The 'type' property of the function does not match an available function. Check your request parameters." });
			//Status.KnownCodes.Add(new Status() { Code = 9, Message = "Invalid selection: The Selection.selectionType property contains an invalid value." });
			//Status.KnownCodes.Add(new Status() { Code = 10, Message = "Invalid page: The page requested in the request is invalid. Occurs if the page is less than 1 or more than the number of available pages for the request." });
			//Status.KnownCodes.Add(new Status() { Code = 11, Message = "Function error: An error occurred processing a function. Ensure required properties are provided." });
			//Status.KnownCodes.Add(new Status() { Code = 12, Message = "Post not supported for request: The request URL does not support POST." });
			//Status.KnownCodes.Add(new Status() { Code = 13, Message = "Get not supported for request: The request URL does not support GET." });
			//Status.KnownCodes.Add(new Status() { Code = 14, Message = "Authentication token has expired. Refresh your tokens: See Token Refresh." });
			//Status.KnownCodes.Add(new Status() { Code = 15, Message = "Duplicate data violation: Fix the data which is duplicated and re-post." });
			//Status.KnownCodes.Add(new Status() { Code = 16, Message = "Invalid token. Token has been deauthorized by user. You must re-request authorization." });
		}

		/// <summary>
		/// The status code for this status.
		/// </summary>
		[JsonProperty(PropertyName = "code")]
		public int Code
		{
			get
			{
				return _code;
			}
			set
			{
				_code= value;
			}
		}


		/// <summary>
		/// The detailed message for this status. 
		/// </summary>
		[JsonProperty(PropertyName = "message")]
		public string Message
		{
			get
			{
				return _message;
			}
			set
			{
				_message= value;
			}
		}

		//public static List<Status> KnownCodes
		//{
		//	get
		//	{
		//		return Status._knownCodes;
		//	}
		//}
	}
}
